package com.zzc.controller;

import com.zzc.common.JsonResult;
import com.zzc.common.TableResult;
import com.zzc.pojo.Customer;
import com.zzc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhouzhicheng
 * @version 1.0  2020/12/29
 */
@RestController
@RequestMapping("/sys/customer")
public class CustomerController {
    @Autowired
    private CustomerService customerService;
    @RequestMapping("/table")
    public TableResult getCustomer(Integer page,Integer limit,String name, Integer state){
      return customerService.getCustomer(page, limit, name, state);
    }
    @RequestMapping("/del")
    public JsonResult deleteCustomersById(Integer[] ids){
        return customerService.deleteCustomersById(ids);
    }
    @RequestMapping("/add")
    public JsonResult addCustomer(Customer customer){
        return customerService.insertSelective(customer);
    }
    @RequestMapping("/update")
    public JsonResult updateCustomer(Customer customer){
        return customerService.updateByPrimaryKeySelective(customer);
    }
    @RequestMapping("/tree")
    public List<Customer> getCustomerName(){
        return customerService.getAllCustomer();
    }
}
